Skip to content

fix(tests): align SSE and quantum integration tests with current APIs#475

Merged
Bryan-Roe merged 1 commit into
mainfrom
cursor/repository-automation-3dbd
Jun 21, 2026
Merged

fix(tests): align SSE and quantum integration tests with current APIs#475
Bryan-Roe merged 1 commit into
mainfrom
cursor/repository-automation-3dbd

Conversation

@cursor

@cursor cursor Bot commented Jun 21, 2026

Copy link
Copy Markdown

Summary

Hourly repo health automation cycle (2026-06-21 02:02 UTC) failed pre-commit due to 6 unit test regressions. This PR fixes the test drift and restores a green health cycle.

Changes

  • Add _capture_sse_http_response helper to capture materialized SSE byte bodies from _sse_response (not just generators)
  • Update fetch_similar_messages mock in chat stream tests to accept min_similarity kwarg
  • Restore whitelisted smoke job name in tests/test_quantum_integration.py (replacing invalid another)

Verification

  • .venv/bin/python -m pytest on affected tests: 6 passed
  • Full health cycle: PYTHON_BIN=.venv/bin/python scripts/repo_health_automation.py --once --repair-status --refresh-stale-status --run-agents --continue-on-fail — all steps passed (2747 unit tests, integration gate, agents)
Open in Web View Automation 

Summary by Sourcery

Align SSE chat/AGI streaming tests and quantum integration tests with updated APIs to restore passing test suite.

Bug Fixes:

  • Capture SSE HTTP response bodies as bytes or generators in shared test helper to prevent streaming-related regressions.
  • Update chat stream tests to mock fetch_similar_messages with the new min_similarity parameter and ensure SSE bodies are fully materialized.
  • Adjust quantum integration autorun job tests to use the valid smoke job name in both payloads and assertions.

Tests:

  • Refactor multiple SSE-related tests to use a shared helper for capturing HttpResponse bodies.

Note

Low Risk
Test-only refactors and fixture updates; no runtime behavior in application code is modified.

Overview
Restores failing unit tests after API and validation drift, with no production code changes.

SSE streaming tests gain a shared _capture_sse_http_response helper that records SSE payloads whether HttpResponse is built from a generator or pre-materialized bytes (e.g. guardrail-blocked streams). Chat/AGI stream tests that duplicated inline HttpResponse patches now call this helper.

Chat stream mocks for fetch_similar_messages accept the min_similarity keyword that function_app now passes when injecting memory.

Quantum integration autorun tests use the whitelisted job name smoke instead of another in fixtures and assertions.

Reviewed by Cursor Bugbot for commit eb3f478. Bugbot is set up for automated code reviews on this repo. Configure here.

Update stream endpoint tests to capture materialized SSE byte bodies from
_sse_response and accept min_similarity in fetch_similar_messages mocks.
Use whitelisted smoke job name in quantum autorun integration test.

Co-authored-by: Bryan
@github-actions github-actions Bot added the tests label Jun 21, 2026
@sourcery-ai

sourcery-ai Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Introduces a reusable helper for capturing SSE HttpResponse bodies in streaming tests, updates chat stream mocks to match the current fetch_similar_messages signature, and restores the expected smoke job name in quantum integration tests so autorun status checks align with real job configurations.

File-Level Changes

Change Details Files
Introduce reusable helper to capture SSE HttpResponse bodies as bytes in streaming tests and apply it across SSE-based chat and AGI tests.
  • Add _capture_sse_http_response helper that wraps azure.functions.HttpResponse to consume generator bodies into bytes and record them in a shared capture dict
  • Use the new helper in chat stream guardrail, memory injection, and done-sentinel tests to replace ad-hoc capturing HttpResponse monkeypatch implementations
  • Ensure the helper records both generator and byte/bytearray bodies into captured['sse_body'] for later SSE assertions
tests/test_function_app_endpoints.py
Align chat stream test mocks with updated fetch_similar_messages API to accept min_similarity parameter.
  • Update _fake_similar mock in chat stream memory injection test to include min_similarity keyword argument with default 0.0
  • Adjust lambda-based fetch_similar_messages mock in done-sentinel chat stream test to accept min_similarity keyword argument with default 0.0
tests/test_function_app_endpoints.py
Restore the expected 'smoke' autorun job name in quantum integration tests so they mirror real job configurations.
  • Change parametrized jobs_payload fixtures to use job name 'smoke' instead of 'another' for both list and dict payload shapes
  • Update run_autorun_job invocation to request job 'smoke' instead of 'another'
  • Adjust assertions to expect job_name and status['name'] to be 'smoke'
tests/test_quantum_integration.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions

Copy link
Copy Markdown

🟡 Coverage — 50f2cd9

Metric Value
Total coverage 65.2%
▲ vs main +0.1%
Minimum threshold 60%

Updated on every push · 2026-06-21

@Bryan-Roe Bryan-Roe marked this pull request as ready for review June 21, 2026 02:17
@Bryan-Roe Bryan-Roe self-requested a review as a code owner June 21, 2026 02:17
Copilot AI review requested due to automatic review settings June 21, 2026 02:17
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@Bryan-Roe Bryan-Roe merged commit 09f3b91 into main Jun 21, 2026
44 of 70 checks passed

Copilot AI commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

@Bryan-Roe Thanks for sending me some feedback. Unfortunately, I hit an error while trying to use the custom Copilot setup steps configured for this repository. The error I am seeing is:

no `copilot-setup-steps` job found in your `copilot-setup-steps.yml` workflow file. Please ensure you have a single job named `copilot-setup-steps`. For more details, see https://gh.io/copilot/actions-setup-steps

Once you or someone with the necessary access fixes the problem, please let me know in a comment and I'll try again. Thanks!

@Bryan-Roe Bryan-Roe deleted the cursor/repository-automation-3dbd branch June 21, 2026 02:17
Copilot stopped reviewing on behalf of Bryan-Roe due to an error June 21, 2026 02:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR is a test-only refactoring. It deduplicates repeated SSE response-capturing logic in the Function App endpoint tests into a shared helper, updates a stub lambda to match an extended fetch_similar_messages signature, and renames a quantum integration test job from another to smoke.

Changes:

  • Extracted a reusable _capture_sse_http_response helper to replace four copies of the inline HttpResponse-capturing logic, and added byte-body capture support.
  • Updated the fetch_similar_messages stub lambda to include the min_similarity keyword argument.
  • Renamed the test job identifier from another to smoke in the quantum integration parametrized test and its assertions.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/test_function_app_endpoints.py Consolidates duplicated SSE capture logic into a helper and aligns a stub signature with the updated API.
tests/test_quantum_integration.py Renames the test job name to smoke for clearer test intent.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="tests/test_function_app_endpoints.py" line_range="550" />
<code_context>
+        def _fake_similar(query_emb, top_k=5, session_id=None, min_similarity=0.0):
</code_context>
<issue_to_address>
**suggestion (testing):** Assert on the `min_similarity` argument passed into `fetch_similar_messages` to fully cover the updated signature.

Right now the mock accepts `min_similarity` but the test doesn’t check what value is passed. Capture the received `min_similarity` in `captured` (e.g., `captured['min_similarity'] = min_similarity`) and assert on it so the test explicitly verifies the intended default/configured value and guards against future signature drift.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.


monkeypatch.setattr(app_module.func, "HttpResponse",
_capturing_HttpResponse)
_capture_sse_http_response(monkeypatch, app_module, captured)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (testing): Assert on the min_similarity argument passed into fetch_similar_messages to fully cover the updated signature.

Right now the mock accepts min_similarity but the test doesn’t check what value is passed. Capture the received min_similarity in captured (e.g., captured['min_similarity'] = min_similarity) and assert on it so the test explicitly verifies the intended default/configured value and guards against future signature drift.

@cursor

cursor Bot commented Jun 21, 2026

Copy link
Copy Markdown
Author

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_4170bb7a-204c-45b6-b3bf-dbb7c2d94054)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants